from sqlalchemy.orm import Session
import json
from typing import List
from app.entity import Activity
from app.schema import DeptData
from utils.request import PageInfo
from utils.tree import TreeUtil

class ActivityModel:
   
    @classmethod
    def get_page(cls, db: Session, where:dict, page: PageInfo ):
        total = db.query(Activity).filter_by(**where).count()
        rows  = db.query(Activity).filter_by(**where).offset((page.page-1)*page.limit).limit(page.limit).all()
        
        return total, rows

    @classmethod
    def get_by_id(cls, db: Session, id: int):
        return db.query(Activity).filter(Activity.act_id==id).first()
    
        
 